
setTimeout(function(){
	$("#roleName").val('');
	$("#roleName").focus();
	$("#roleName").rules("add",{
		remote: {
			url: 'sys/roles/checkName'+($("#roleName").val()+""),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			}
		}, 
		
		messages: {remote: "该角色名称已添加"}
		
	});  
} , parseInt(Math.random() * 1000)); 


var app = angular.module('roleApp', []);



app.controller('roleController', function($scope, $http) {
	$scope.role;
	
	$scope.refreshData=function(){
		$scope.role={};
	}
	
	$scope.roleSave=function(){
	   if($("#myForm").valid()){
		   $http.post('sys/roles/add/', $scope.role).success(function(){
			   redirectUrl("manage/role/","list.jsp");
           });
	   }
	}
	
	$scope.roleReset=function(){
		$scope.role={};
	}
	
	$scope.roleCancle=function(){
		redirectUrl("manage/role/","list.jsp");
	}
});